<template>
  <div
    class="menuNavigation-box"
    :class="{
      'menuNavigation-item-loop': !route.meta.loopType,
      'menuNavigation-item-wap': store.isMobileType,
    }"
  >
    <div class="menuNavigation-box-child">
      <div @click="openprogres" id="menuNavigation-item" class="menuNavigation-item">
        <t-popup
          class="placement align"
          content="展览定位"
          placement="left"
          attach="#menuNavigation-item8"
          showArrow
          destroyOnClose
        >
          <div
            class="item-box"
            id="menuNavigation-item8"
            :class="{ 'item-active': showType === 1, 'is-hover': store.isMobileType }"
          >
            <div
              class="item-bg"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationBg.png?imageView2/format/webp'})`,
              }"
            ></div>
            <div
              class="item-content"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationIcon8.png?imageView2/format/webp'})`,
              }"
            ></div>
          </div>
        </t-popup>
      </div>
      <div @click="handleMouseEnter(1)" id="menuNavigation-item" class="menuNavigation-item">
        <t-popup
          class="placement align"
          content="更多板块"
          placement="left"
          attach="#menuNavigation-item1"
          showArrow
          destroyOnClose
        >
          <div
            class="item-box"
            id="menuNavigation-item1"
            :class="{ 'item-active': showType === 1, 'is-hover': store.isMobileType }"
          >
            <div
              class="item-bg"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationBg.png?imageView2/format/webp'})`,
              }"
            ></div>
            <div
              class="item-content"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationIcon1.png?imageView2/format/webp'})`,
              }"
            ></div>
          </div>
        </t-popup>
      </div>
      <div @click="handleMouseEnter(2)" class="menuNavigation-item">
        <t-popup
          class="placement align"
          content="单元目录"
          placement="left"
          attach="#menuNavigation-item2"
          showArrow
          destroyOnClose
        >
          <div
            class="item-box"
            id="menuNavigation-item2"
            :class="{ 'item-active': showType === 2, 'is-hover': store.isMobileType }"
          >
            <div
              class="item-bg"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationBg.png?imageView2/format/webp'})`,
              }"
            ></div>
            <div
              class="item-content"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationIcon2.png?imageView2/format/webp'})`,
              }"
            ></div>
          </div>
        </t-popup>
      </div>
      <div class="menuNavigation-item" v-if="!store.isMobileType">
        <t-popup
          class="placement align"
          content="收藏此展览"
          placement="left"
          attach="#menuNavigation-item4"
          showArrow
          destroyOnClose
        >
          <!-- :class="{ 'item-active': showType === 3, 'is-hover': store.isMobileType }" -->
          <div class="item-box" id="menuNavigation-item4" @click="follow">
            <div
              class="item-bg"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationBg.png?imageView2/format/webp'})`,
              }"
            ></div>
            <div v-if="commonStore.isStart" class="item-content doorIcon item-start">&#xe629;</div>
            <div
              class="item-content"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationIcon3.png?imageView3/format/webp'})`,
              }"
              v-else
            ></div>
            <!-- <div v-if="commonStore.isStart" class="item-content doorIcon item-start start-active">&#xe629;</div> -->
          </div>
        </t-popup>
      </div>
      <div class="menuNavigation-item" v-if="!store.isMobileType">
        <t-popup
          class="placement align"
          content=""
          placement="left"
          attach="#menuNavigation-item5"
          destroyOnClose
          :trigger="store.isMobileType ? 'click' : 'hover'"
          :overlay-inner-style="(triggerElem) => ({ background: `transparent`, 'box-shadow': 'none' })"
        >
          <template #content>
            <Shear @shearType="shearType" />
          </template>
          <div class="item-box" id="menuNavigation-item5" :class="{ 'item-active': showType === 4 }">
            <div
              class="item-bg"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationBg.png?imageView2/format/webp'})`,
              }"
            ></div>
            <div
              class="item-content"
              :style="{
                backgroundImage: `url(${publicUrls + 'free/style14/menuNavigationIcon4.png?imageView2/format/webp'})`,
              }"
            ></div>
          </div>
        </t-popup>
      </div>
    </div>
    <div
      class="scroll-box"
      v-if="(showType === 1 || showType === 2 || showType === 4) && show"
      :class="showType === 1 || showType === 2 || showType === 4 ? 'scroll-box-active' : 'scroll-box-down'"
    >
      <div
        class="scroll-box-content"
        :style="{
          backgroundImage: `url(${publicUrls + 'free/style14/scrollMenuBg.png'})`,
        }"
      >
        <div class="list-content">
          <div class="list-head">{{ showType === 1 ? '更多板块' : '单元目录' }}</div>
          <div
            class="list-scroll"
            :class="{
              'list-scroll1': showType === 1,
              'list-scroll2': showType === 2,
              'list-scroll3': store.templateMOdeList.length < 6,
            }"
          >
            <div
              class="item"
              :class="{ 'item-active': listId === item.id }"
              @click="scroolPath(item.id)"
              v-for="item in store.templateMOdeList"
              :key="item.id"
              v-if="showType === 2"
            >
              <p class="item-title" :class="!store.isMobileType && 'item-hover'">{{ item.text }}</p>
            </div>
            <div class="item2" v-if="showType === 1">
              <RouterList @emitPath="scrollHandleMouseLeave" />
            </div>
          </div>
        </div>
      </div>
    </div>
    <div
      @wheel="pageWheel"
      class="shadow"
      @click="close"
      v-if="(showType === 1 || showType === 2 || showType === 4) && show"
    ></div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style14',
});
</script>
<script lang="ts" setup>
import { getHeardToken } from '@/api/utils';
import { psthOutline } from '@/hooks/menuHooks';
import RouterList from '../menuComponent/routerList14.vue';
import { publicUrls } from '@/utils/minxin';
import { ref, reactive, watch, nextTick, computed, defineComponent } from 'vue';
import { useProjectStore } from '@/store';
import { commonDataStore } from '@/store';
import { toQQ, toQQzone, toWeibo } from '@/utils/shear';
import { AddFollow } from '@/api/door/door';
import Shear from '../menuComponent/templateShear.vue';
import { useRoute, useRouter } from 'vue-router';

const props = defineProps({
  isMobile: {
    type: Boolean,
  },
});
const commonStore = commonDataStore();
const show = ref(false);
const showType = ref(0);
const listId = ref(0);
const store = useProjectStore();
const visibleMessage = ref(false);
const FollowType = ref(false);
const router = useRouter();
const route = useRoute();
const shareList = reactive([
  {
    icon: '\ue623',
    text: '分享此展览到QQ',
  },
  {
    icon: '\ue616',
    text: '分享此展览到QQ空间',
  },
  {
    icon: '\ue615',
    text: '分享此展览到微博',
  },
]);

commonStore.getMenuList();
const handleMouseEnter = (type: number) => {
  showType.value = type;
  show.value = true;
};

const mouseenterHover = () => {};

const scrollHandleMouseLeave = () => {
  showType.value = 0;
  show.value = false;
};
const openprogres = () => {
  store.setprogressVisible();
};
const scroolPath = (id: number) => {
  if (route.name !== 'templateedit') {
    router.push({ name: route.meta.loopType ? 'exhibitionHome' : 'templateedit' });
    store.menuId = null;
  }
  if (id !== 0) {
    setTimeout(() => {
      psthOutline('Level1outline' + id);
      scrollHandleMouseLeave();
      listId.value = id;
    }, 200);
  } else {
    const el = document.getElementById('edit-scroll-box');
    store.bannerShow = false;
    store.bannerLock = false;
    setTimeout(() => {
      el.scrollTo({
        left: 0,
      });
    }, 1000);
  }
};
const follow = () => {
  let token = getHeardToken();
  if (!token) {
    // visibleMessage.value = true;
    store.loginModeShow = true;
    return;
  } else {
    commonStore.setFollow();
    handleMouseEnter(3);
  }
};
const pageWheel = (event: any) => {
  const delta = Math.sign(event.wheelDelta || -event.detail);
  const scrollContainer = document.getElementById('edit-scroll-box');
  if (delta > 0) {
    if (scrollContainer.scrollLeft === 0) {
    } else {
      scrollContainer.scrollLeft = scrollContainer.scrollLeft - 100;
    }
  } else {
    scrollContainer.scrollLeft = scrollContainer.scrollLeft + 100;
  }
  event.preventDefault();

  // scrollRef
};
//分享
const shearType = (e: number) => {
  let url = window.location.href;
  let title = '';
  handleMouseEnter(4);
  switch (e) {
    case 0:
      toQQ(url, title);
      break;
    case 1:
      toQQzone(url, title);
      break;
    case 2:
      toWeibo(url, title);
      break;
  }
  scrollHandleMouseLeave();
};

//取消登录
const closeClick = () => {
  visibleMessage.value = false;
};
const close = () => {
  showType.value = 0;
  show.value = false;
};
//确认登录
const pathSubmitClick = () => {
  visibleMessage.value = false;
  let url = window.location.href;
  let redirectUrl = 'http://wz.wuzhan.art/#/login?redirect=' + url;
  window.location.href = redirectUrl;
};
</script>

<style lang="less" scoped>
a {
  color: #000;
  &:hover {
    color: #000;
  }
}
.shadow {
  position: fixed;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
  // z-index: 19;
}
.menuNavigation-box {
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 200px;
  right: 42px;
  // right: 0px;
  width: 50px;
  z-index: 999;
}
.menuNavigation-box-child {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.menuNavigation-item {
  flex-shrink: 0;
  width: 100%;
  height: 50px;
  cursor: pointer;
  margin-bottom: 26px;
}
.menuNavigation-item:hover {
  .item-bg {
    transform: rotate(45deg);
  }
}
.item-box {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
}
.item-bg {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  transition: all 0.5s;
}
.item-content {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%) translateY(-50%) translateZ(2px);
  width: 28px;
  height: 28px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.item-start {
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: -webkit-linear-gradient(-41deg, #fff 38%, rgba(255, 255, 255, 0.6) 92.76%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.menuNavigation-item-wap {
  bottom: 100px;

  .menuNavigation-item {
    // transform: translateZ(1px);
    transform: scale(1.5) translateZ(2px);
    margin-top: 42px;
  }
  .scroll-box {
    transform: scale(1.3) translateZ(2px);
    margin-bottom: 80px;
    right: 210px;
  }
  ::v-deep .t-popup {
    display: none;
  }
}
::v-deep .t-popup__content {
  width: 88px;
  height: 33px;
  display: inline-flex;
  padding: 2px 12px;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border-radius: 4px;
  background: #269df1;
  color: #fff;
  text-align: justify;
  font-family: 'Microsoft YaHei';
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 180%; /* 28.8px */
  white-space: nowrap;
  box-shadow: none;
  .pop-box-parent {
    margin-right: 180px;
  }
}
::v-deep .t-popup__arrow::before {
  background: #269df1;
  box-shadow: none !important;
}
.scroll-box {
  display: flex;
  align-items: center;
  position: fixed;
  bottom: 100px;
  right: 102px;
  z-index: 220;
  transform: translateZ(1px);
}
.scroll-box-content {
  width: 300px;
  height: 440px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.list-content {
  width: 286px;
  height: 426px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-direction: column;
  //   justify-content: center;
}
.list-head {
  flex-shrink: 0;
  width: 252px;
  color: #269df1;
  text-align: center;
  font-family: 'SourceHanSerifCN';
  font-size: 18px;
  font-style: normal;
  font-weight: 700;
  line-height: 180%; /* 32.4px */
  margin-top: 6px;
}
.list-scroll {
  flex: 1;
  width: 256px;
  // height: 308px;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-width: none;
  &::-webkit-scrollbar {
    display: none;
  }
}
.list-scroll3 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.list-scroll2 {
  margin-top: 36px;
}
.list-scroll1 {
  margin-top: 24px;
  // overflow: hidden;
  width: 256px;
  // height: auto;
}
.item {
  margin-bottom: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  &:last-child {
    margin-bottom: 0;
  }
}
.item:hover {
  .item-hover {
    color: #269df1;
  }
}
.item-active {
  .item-title {
    color: #269df1;
    text-decoration-line: underline;
    text-underline-offset: 2px;
  }
  .item-bg {
    transform: rotate(45deg);
  }
}
.item-title {
  color: #0b36b5;
  font-family: 'PingFang SC';
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 200%; /* 32px */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item2 {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
}
</style>
